<?php
declare (strict_types=1);

namespace app\common\model;

class Area extends Base
{
    protected $name = 'area';


    public static function getArea($parent_code = 100000, $level = 1)
    {
        $filed = match ($level) {
            1 => 'province as title',
            2 => 'city as title',
            3 => 'district as title',
            4 => 'town as title',
            default => ''
        };

        return parent::where(['parent_code' => $parent_code, 'level' => $level])
            ->field('code,' . $filed)->select();
    }
}
